# @Author : mcyj
# @Time : 2025/2/12 下午10:52

import sys
from PySide6.QtWidgets import QApplication, QMainWindow, QWidget, QFileDialog
from MainWinMenuToolbar import Ui_MainWindow
from PySide6.QtCore import QCoreApplication
import os

class MainWindow(QMainWindow, Ui_MainWindow):
    def __init__(self):
        super(MainWindow, self).__init__()
        self.setupUi(self)
        #菜单的点击事件,当单击关闭菜单时连接槽函数close()
        self.FileCloseAction.triggered.connect(self.close)
        #菜单栏的点击事件,当单击打开文件菜单时连接槽函数openMsg()
        self.FileOpenAction.triggered.connect(self.openFile)

        #打开计算器
        self.openCalc.triggered.connect(lambda: os.system("calc"))
        #打开记事本
        self.openNotepad.triggered.connect(lambda: os.system("notepad"))

    def openFile(self):
        file, ok = QFileDialog.getOpenFileName(self, "打开","C:/", "All Files (*);;Text Files (*.txt)")
        #在状态栏显示文件地址
        self.statusbar.showMessage(file)

if __name__ == '__main__':
    app = QApplication(sys.argv)
    mainWindow = MainWindow()
    mainWindow.show()
    sys.exit(app.exec())
